using System;
using System.Collections.Generic;
using DuplexTransformers;
using DuplexTransformersTests.Subjects.WorldA;
using DuplexTransformersTests.Subjects.WorldB;

namespace DuplexTransformersTests
{
    public class ListMediator<TItemMediator, TLeft, TRight> : ListTransformer<TLeft, TRight> where TItemMediator : ITransformer<TLeft, TRight>
    {
        public ListMediator()
        {
            ItemTransformer = Activator.CreateInstance<TItemMediator>();
        }
    }

    public class ProjectListMediator : ITransformer<IList<Project>, IList<FlatProject>>
    {
        private ProjectTransformer _transformer;

        public ProjectListMediator()
        {
            _transformer = new ProjectTransformer();
        }

        public IList<FlatProject> Invoke(IList<Project> src, IList<FlatProject> current)
        {
            foreach (var project in src)
            {
                current.Add(_transformer.Invoke(project, null));
            }
            return current;
        }

        public IList<Project> Invoke(IList<FlatProject> src, IList<Project> current)
        {
            foreach (var dto in src)
            {
                current.Add(_transformer.Invoke(dto, null));
            }
            return current;
        }
    }
}